home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CRIBBAGE.PAK / BOARD.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  1KB  |  49 lines

  1. //--------------------------------------------------------------------------
  2. // Turbo Cribbage -- Copyright (c) 1995, Borland International
  3. //--------------------------------------------------------------------------
  4. #ifndef BOARD_H
  5. #define BOARD_H
  6.  
  7. #include <owl/window.h>
  8. #include <winsys/color.h>
  9. #include <assert.h>
  10.  
  11. //
  12. // TCribbageBoard -- the cribbage board, used to keep score
  13. //
  14. class TCribbageBoard : public TWindow {
  15.   public:
  16.     TCribbageBoard(TWindow* parent, int x, int y);
  17.     void SetupWindow() {
  18.       TWindow::SetupWindow();
  19.       SetBkgndColor(TColor(128,128,0));
  20.     }
  21.     int GetScore(int player) {
  22.       assert(player==1 || player==0);
  23.       return points[player];
  24.     }
  25.     void Reset();
  26.  
  27.     enum PegType {
  28.       ptPlayer0 = 0,
  29.       ptPlayer1 = 1,
  30.       ptEmpty   = 2
  31.     };
  32.     void PegHole(TDC& dc, int player, int hole, PegType pegType);
  33.     void PegHole(TDC& dc, int player, int hole, int pegType) {
  34.       PegHole(dc, player, hole, (PegType)pegType);
  35.     }
  36.     BOOL AddToScore(int player, int amount);
  37.     void SetPlayerName(int player, const char* name);
  38.     const char *GetPlayerName(int player);
  39.     void Paint(TDC& dc, bool erase, TRect& rect);
  40.  
  41.   private:
  42.     char   playerName[2][11];
  43.     int    points[2];
  44.     int    oldpoints[2];
  45.     TPoint holes[2][123];
  46. };
  47.  
  48. #endif // BOARD_H
  49.